use std::prev instead of --c.end() (#1154)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Sun, 6 Aug 2023 22:59:08 +0000 (16:59 -0600)
committerGitHub <noreply@github.com>
Sun, 6 Aug 2023 22:59:08 +0000 (16:59 -0600)
--c.end() is not guaranteed to compile.

smplrout.cc

index 67187c63832e01c3539e61d0b88f26702e56b164..0e5985ec42f9dcbfb57222eaedc7c37c51611d3a 100644 (file)
@@ -58,6 +58,7 @@
 
 #include <cassert>
 #include <cstdlib>              // for strtol
+#include <iterator>             // for prev
 
 #include <QDateTime>            // for QDateTime
 #include <QHash>                // for QHash
@@ -208,7 +209,7 @@ void SimplifyRouteFilter::routesimple_head(const route_head* rte)
     neighborhood goner = errormap.last();
     goner.wpt->wpt_flags.marked_for_deletion = 1;
     // errormap.remove(lastKey());  // with Qt 5.12.12, 5.15.2 results in asan heap-use-after-free errors in build_extra_tests.sh
-    errormap.erase(--errormap.end()); // in Qt6 can use cend().
+    errormap.erase(std::prev(errormap.end())); // in Qt6 can use cend().
     // wpthash.remove(goner.wpt); // removal not necessary
 
     /* recompute neighbors of point marked for deletion. */